import uniqueId from '@form-create/utils/lib/unique';
import {localeProps, makeRequiredRule} from '../../utils';

const label = '多行文本';
const name = 'jd-textarea';

export default {
    icon: 'icon-textarea',
    label,
    name,
    rule({t}) {
        return {
            type: 'input',
            field: 'DHWB',
            title: '多行文本',
            info: '',
            $required: false,
            validate: false,
            props: { type:'textarea', rows: 5 }
        };
    },
    props(_, {t}) {
        return localeProps(t, name + '.props', [
            {
                type: 'input',
                field: 'placeholder',
                title: '占位文本'
            }, 
            makeRequiredRule(), 
            // {
            //     type: 'select',
            //     field: 'type',
            //     title: '类型',
            //     options: [{label: 'text', value: 'text'}, {
            //         label: 'textarea',
            //         value: 'textarea'
            //     }, {label: 'number', value: 'number'}, {label: 'password', value: 'password'}]
            // },
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'switch', field: 'showWordLimit', title: '显示字数'}, 
                ]
            },
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'inputNumber', field: 'maxlength', title: '最大长度', props: {min: 0, controlsPosition:'right', width: '100%'}}
                ]
            }, 
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'switch', field: 'disabled', title: '是否禁用'}, 
                ]
            },
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'switch', field: 'readonly', title: '是否只读'}, 
                ]
            },
            {
                type: 'inputNumber',
                field: 'rows',
                info: t('components.input.props.rowsInfo'),
                title: '文本行数',
                props: {min: 0},
            }, 
        ]);
    }
};
